package org.jeecg.modules.basesource.utils.cwbb;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.basesource.entity.SbCwbbQykjzzLrb;
import org.jeecg.modules.basesource.entity.SbCwbbQykjzzXjllb;
import org.jeecg.modules.basesource.entity.SbCwbbQykjzzZcfzb;
import org.jeecg.modules.dzswj.vo.response.cwbb.*;

import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author chensherun on 2022/3/3.
 * @version 1.0
 */
@Slf4j
public class CwbbQykjzzWrapperUtil {

    /**
     * 包装企业会计制度利润表
     * @param lrb
     * @param nsrForm
     * @param gridlbList
     */
    public static void wrapperQykjzzLrb(SbCwbbQykjzzLrb lrb, NsrxxForm nsrForm, List<QykjzdcwbblrbxxGridlb> gridlbList) {
        Map<String, QykjzdcwbblrbxxGridlb> ewbhxhMap = gridlbList.stream().collect(Collectors.toMap(QykjzdcwbblrbxxGridlb::getEwbhxh, Function.identity(), (e1, e2) -> e2));
        if (nsrForm != null) {
            try {
                if (StringUtils.isNotBlank(nsrForm.getBsrq())) {
                    lrb.setBsrq(DateUtils.parseDate(nsrForm.getBsrq(), "yyyy-MM-dd"));
                }
            } catch (ParseException e) {
                log.error("日期转换有误:" + nsrForm.getBsrq());
            }
            lrb.setBbssq(nsrForm.getBbssq());
        }
        lrb.setSjcjSj(new Date());

        //1 一、主营业务收入
        lrb.setYzyywsrBys(getLrbBys(ewbhxhMap, 1));
        lrb.setYzyywsrBnljs(getLrbBnljs(ewbhxhMap, 1));
        //2 减:主营业务成本
        lrb.setJzyywcbBys(getLrbBys(ewbhxhMap, 2));
        lrb.setJzyywcbBnljs(getLrbBnljs(ewbhxhMap, 2));
        //3 主营业务税金及附加
        lrb.setZyywsjjfjBys(getLrbBys(ewbhxhMap, 3));
        lrb.setZyywsjjfjBnljs(getLrbBnljs(ewbhxhMap, 3));
        //4 二、主营业务利润(亏损以“-”号填列)
        lrb.setEzyywlrksyhtlBys(getLrbBys(ewbhxhMap, 4));
        lrb.setEzyywlrksyhtlBnljs(getLrbBnljs(ewbhxhMap, 4));
        //5 加:其他业务利润(亏损“-”号填列)
        lrb.setJqtywlrkshtlBys(getLrbBys(ewbhxhMap, 5));
        lrb.setJqtywlrkshtlBnljs(getLrbBnljs(ewbhxhMap, 5));
        //6 减:营业费用
        lrb.setJyyfyBys(getLrbBys(ewbhxhMap, 6));
        lrb.setJyyfyBnljs(getLrbBnljs(ewbhxhMap, 6));
        //7 管理费用
        lrb.setGlfyBys(getLrbBys(ewbhxhMap, 7));
        lrb.setGlfyBnljs(getLrbBnljs(ewbhxhMap, 7));
        //8 财务费用
        lrb.setCwfyBys(getLrbBys(ewbhxhMap, 8));
        lrb.setCwfyBnljs(getLrbBnljs(ewbhxhMap, 8));
        //9 三、营业利润(亏损以“-”号填列)
        lrb.setSyylrksyhtlBys(getLrbBys(ewbhxhMap, 9));
        lrb.setSyylrksyhtlBnljs(getLrbBnljs(ewbhxhMap, 9));
        //10 加:投资收益(损失以“-”填列)
        lrb.setJtzsyssytlBys(getLrbBys(ewbhxhMap, 10));
        lrb.setJtzsyssytlBnljs(getLrbBnljs(ewbhxhMap, 10));
        //11 补贴收入
        lrb.setBtsrBys(getLrbBys(ewbhxhMap, 11));
        lrb.setBtsrBnljs(getLrbBnljs(ewbhxhMap, 11));
        //12 营业外收入
        lrb.setYywsrBys(getLrbBys(ewbhxhMap, 12));
        lrb.setYywsrBnljs(getLrbBnljs(ewbhxhMap, 12));
        //13 减:营业外支出
        lrb.setJyywzcBys(getLrbBys(ewbhxhMap, 13));
        lrb.setJyywzcBnljs(getLrbBnljs(ewbhxhMap, 13));
        //14 四、利润总额(亏损总额以“-”号填列)
        lrb.setSlrzekszeyhtlBys(getLrbBys(ewbhxhMap, 14));
        lrb.setSlrzekszeyhtlBnljs(getLrbBnljs(ewbhxhMap, 14));
        //15 减:所得税
        lrb.setJsdsBys(getLrbBys(ewbhxhMap, 15));
        lrb.setJsdsBnljs(getLrbBnljs(ewbhxhMap, 15));
        //16 五、净利润(净亏损以“-”号填列)
        lrb.setWjlrjksyhtlBys(getLrbBys(ewbhxhMap, 16));
        lrb.setWjlrjksyhtlBnljs(getLrbBnljs(ewbhxhMap, 16));
        //17 1.出售、处置部门或被投资单位所得收益
        lrb.setCsczbmhbtzdwsdsyBys(getLrbBys(ewbhxhMap, 17));
        lrb.setCsczbmhbtzdwsdsyBnljs(getLrbBnljs(ewbhxhMap, 17));
        //18 2.自然灾害发生的损失
        lrb.setZrzhfsdssBys(getLrbBys(ewbhxhMap, 18));
        lrb.setZrzhfsdssBnljs(getLrbBnljs(ewbhxhMap, 18));
        //19 3.会计政策变更增加(或减少)利润总额
        lrb.setHjzcbgzjhjslrzeBys(getLrbBys(ewbhxhMap, 19));
        lrb.setHjzcbgzjhjslrzeBnljs(getLrbBnljs(ewbhxhMap, 19));
        //20 4.会计估计变更增加(或减少)利润总额
        lrb.setHjgjbgzjhjslrzeBys(getLrbBys(ewbhxhMap, 20));
        lrb.setHjgjbgzjhjslrzeBnljs(getLrbBnljs(ewbhxhMap, 20));
        //21 5.债务重组损失
        lrb.setZwzzssBys(getLrbBys(ewbhxhMap, 21));
        lrb.setZwzzssBnljs(getLrbBnljs(ewbhxhMap, 21));
        //22 6.其他
        lrb.setQtBys(getLrbBys(ewbhxhMap, 22));
        lrb.setQtBnljs(getLrbBnljs(ewbhxhMap, 22));
    }

    /**
     * 包装企业会计制度现金流量表
     * @param xjllb
     * @param nsrForm
     * @param gridlbList
     */
    public static void wrapperQykjzzXjllb(SbCwbbQykjzzXjllb xjllb, NsrxxForm nsrForm, List<QykjzdcwbbxjllbxxGridlb> gridlbList) {
        Map<String, QykjzdcwbbxjllbxxGridlb> ewbhxhMap = gridlbList.stream().collect(Collectors.toMap(QykjzdcwbbxjllbxxGridlb::getEwbhxh, Function.identity(), (e1, e2) -> e2));
        if (nsrForm != null) {
            try {
                if (StringUtils.isNotBlank(nsrForm.getBsrq())) {
                    xjllb.setBsrq(DateUtils.parseDate(nsrForm.getBsrq(), "yyyy-MM-dd"));
                }
            } catch (ParseException e) {
                log.error("日期转换有误:" + nsrForm.getBsrq());
            }
            xjllb.setBbssq(nsrForm.getBbssq());
        }
        xjllb.setSjcjSj(new Date());

        //1  销售商品、提供劳务收到的现金
        xjllb.setXssptglwsddxjJe(getXjllbJe(ewbhxhMap, 1));
        //2  收到的税费返还
        xjllb.setSddsffhJe(getXjllbJe(ewbhxhMap, 2));
        //3  收到的其他与经营活动有关的现金
        xjllb.setSddqtyjyhdygdxjJe(getXjllbJe(ewbhxhMap, 3));
        //4  现金流入小计
        xjllb.setXjlrxjJe(getXjllbJe(ewbhxhMap, 4));
        //5  购买商品、接受劳务支付的现金
        xjllb.setGmspjslwzfdxjJe(getXjllbJe(ewbhxhMap, 5));
        //6  支付给职工以及为职工支付的现金
        xjllb.setZfgzgyjwzgzfdxjJe(getXjllbJe(ewbhxhMap, 6));
        //7  支付的各项税费
        xjllb.setZfdgxsfJe(getXjllbJe(ewbhxhMap, 7));
        //8  支付的其他与经营活动有关的现金
        xjllb.setZfdqtyjyhdygdxjJe(getXjllbJe(ewbhxhMap, 8));
        //9  现金流出小计
        xjllb.setXjlcxjJe(getXjllbJe(ewbhxhMap, 9));
        //10 经营活动产生的现金流量净额
        xjllb.setJyhdcsdxjlljeJe(getXjllbJe(ewbhxhMap, 10));
        //11 收回投资所收到的现金
        xjllb.setShtzssddxjJe(getXjllbJe(ewbhxhMap, 11));
        //12 取得投资收益所收到的现金
        xjllb.setQdtzsyssddxjJe(getXjllbJe(ewbhxhMap, 12));
        //13 处置固定资产、无形资产和其他长期资产所收回的现金净额
        xjllb.setCzgdzcwxzchqtcqzcsshdxjjeJe(getXjllbJe(ewbhxhMap, 13));
        //14 收到的其他与投资活动有关的现金
        xjllb.setSddqtytzhdygdxjJe(getXjllbJe(ewbhxhMap, 14));
        //15 现金流入小计 (投资活动现金流入小计)
        xjllb.setTzhdxjlrxjJe(getXjllbJe(ewbhxhMap, 15));
        //16 购建固定资产、无形资产和其他长期资产所支付的现金
        xjllb.setGjgdzcwxzchqtcqzcszfdxjJe(getXjllbJe(ewbhxhMap, 16));
        //17 投资所支付的现金
        xjllb.setTzszfdxjJe(getXjllbJe(ewbhxhMap, 17));
        //18 支付的其他与投资活动有关的现金
        xjllb.setZfdqtytzhdygdxjJe(getXjllbJe(ewbhxhMap, 18));
        //19 现金流出小计 (投资活动现金流出小计)
        xjllb.setTzhdxjlcxjJe(getXjllbJe(ewbhxhMap, 19));
        //20 投资活动产生的现金流量净额
        xjllb.setTzhdcsdxjlljeJe(getXjllbJe(ewbhxhMap, 20));
        //21 吸收投资所收到的现金
        xjllb.setXstzssddxjJe(getXjllbJe(ewbhxhMap, 21));
        //22 借款所收到的现金
        xjllb.setJkssddxjJe(getXjllbJe(ewbhxhMap, 22));
        //23 收到的其他与筹资活动有关的现金
        xjllb.setSddqtyczhdygdxjJe(getXjllbJe(ewbhxhMap, 23));
        //24 现金流入小计 (筹资活动现金流入小计)
        xjllb.setCzhdxjlrxjJe(getXjllbJe(ewbhxhMap, 24));
        //25 偿还债务所支付的现金
        xjllb.setChzwszfdxjJe(getXjllbJe(ewbhxhMap, 25));
        //26 分配股利、利润或偿付利息所支付的现金
        xjllb.setFpgllrhcflxszfdxjJe(getXjllbJe(ewbhxhMap, 26));
        //27 支付的其他与筹资活动有关的现金
        xjllb.setZfdqtyczhdygdxjJe(getXjllbJe(ewbhxhMap, 27));
        //28 现金流出小计 (筹资活动现金流出小计)
        xjllb.setCzhdxjlcxjJe(getXjllbJe(ewbhxhMap, 28));
        //29 筹资活动产生的现金流量净额
        xjllb.setCzhdcsdxjlljeJe(getXjllbJe(ewbhxhMap, 29));
        //30 四、汇率变动对现金的影响
        xjllb.setShlbddxjdyxJe(getXjllbJe(ewbhxhMap, 30));
        //31 五、现金及现金等价物净增加额
        xjllb.setWxjjxjdjwjzjeJe(getXjllbJe(ewbhxhMap, 31));
        //32 净利润
        xjllb.setJlrJe(getXjllbJe(ewbhxhMap, 32));
        //33 加:计提的资产减值准备
        xjllb.setJjtdzcjzzbJe(getXjllbJe(ewbhxhMap, 33));
        //34 固定资产折旧
        xjllb.setGdzczjJe(getXjllbJe(ewbhxhMap, 34));
        //35 无形资产摊销
        xjllb.setWxzctxJe(getXjllbJe(ewbhxhMap, 35));
        //36 长期待摊费用摊销
        xjllb.setCqdtfytxJe(getXjllbJe(ewbhxhMap, 36));
        //37 待摊费用减少(减:增加)
        xjllb.setDtfyjsjzjJe(getXjllbJe(ewbhxhMap, 37));
        //38 预提费用增加(减:减少)
        xjllb.setYtfyzjjjsJe(getXjllbJe(ewbhxhMap, 38));
        //39 处置固定资产、无形资产和其他长期资产的损失(减:收益)
        xjllb.setCzgdzcwxzchqtcqzcdssjsyJe(getXjllbJe(ewbhxhMap, 39));
        //40 固定资产报废损失
        xjllb.setGdzcbfssJe(getXjllbJe(ewbhxhMap, 40));
        //41 财务费用
        xjllb.setCwfyJe(getXjllbJe(ewbhxhMap, 41));
        //42 投资损失(减:收益)
        xjllb.setTzssjsyJe(getXjllbJe(ewbhxhMap, 42));
        //43 递延税款贷项(减:借项)
        xjllb.setDyskdxjjxJe(getXjllbJe(ewbhxhMap, 43));
        //44 存货的减少(减:增加)
        xjllb.setChdjsjzjJe(getXjllbJe(ewbhxhMap, 44));
        //45 经营性应收项目的减少(减:增加)
        xjllb.setJyxysxmdjsjzjJe(getXjllbJe(ewbhxhMap, 45));
        //46 经营性应付项目的增加(减:减少)
        xjllb.setJyxyfxmdzjjjsJe(getXjllbJe(ewbhxhMap, 46));
        //47 其他
        xjllb.setQtJe(getXjllbJe(ewbhxhMap, 47));
        //48 经营活动产生的现金流量净额 (补充资料经营活动产生的现金流量净额)
        xjllb.setBczljyhdcsdxjlljeJe(getXjllbJe(ewbhxhMap, 48));
        //49 债务转为资本
        xjllb.setZwzwzbJe(getXjllbJe(ewbhxhMap, 49));
        //50 一年内到期的可转换公司债券
        xjllb.setYnndqdkzhgszqJe(getXjllbJe(ewbhxhMap, 50));
        //51 融资租入固定资产
        xjllb.setRzzrgdzcJe(getXjllbJe(ewbhxhMap, 51));
        //52 现金的期末余额
        xjllb.setXjdqmyeJe(getXjllbJe(ewbhxhMap, 52));
        //53 减:现金的期初余额
        xjllb.setJxjdqcyeJe(getXjllbJe(ewbhxhMap, 53));
        //54 加:现金等价物的期末余额
        xjllb.setJxjdjwdqmyeJe(getXjllbJe(ewbhxhMap, 54));
        //55 减:现金等价物的期初余额
        xjllb.setJxjdjwdqcyeJe(getXjllbJe(ewbhxhMap, 55));
        //56 现金及现金等价物净增加额
        xjllb.setXjjxjdjwjzjeJe(getXjllbJe(ewbhxhMap, 56));
    }

    /**
     * 包装企业会计制度现金资产负债表
     * @param zcfzb
     * @param nsrForm
     * @param gridlbList
     */
    public static void wrapperQykjzzZcfzb(SbCwbbQykjzzZcfzb zcfzb, NsrxxForm nsrForm, List<ZcfzbdxxGridlb> gridlbList) {
        Map<String, ZcfzbdxxGridlb> ewbhxhMap = gridlbList.stream().collect(Collectors.toMap(ZcfzbdxxGridlb::getEwbhxh, Function.identity(), (e1, e2) -> e2));
        if (nsrForm != null) {
            zcfzb.setBbssq(nsrForm.getBbssq());
        }
        zcfzb.setSjcjSj(new Date());

        //1  ZC:货币资金  QY:短期借款
        zcfzb.setHbzjQmsZc(getZcfzQmsZc(ewbhxhMap, 1));
        zcfzb.setHbzjNcsZc(getZcfzNcsZc(ewbhxhMap, 1));
        zcfzb.setDqjkQmsQy(getZcfzQmsQy(ewbhxhMap, 1));
        zcfzb.setDqjkNcsQy(getZcfzNcsQy(ewbhxhMap, 1));
        //2  ZC:短期投资  QY:应付票据
        zcfzb.setDqtzQmsZc(getZcfzQmsZc(ewbhxhMap, 2));
        zcfzb.setDqtzNcsZc(getZcfzNcsZc(ewbhxhMap, 2));
        zcfzb.setYfpjQmsQy(getZcfzQmsQy(ewbhxhMap, 2));
        zcfzb.setYfpjNcsQy(getZcfzNcsQy(ewbhxhMap, 2));
        //3  ZC:应收票据  QY:应付账款
        zcfzb.setYspjQmsZc(getZcfzQmsZc(ewbhxhMap, 3));
        zcfzb.setYspjNcsZc(getZcfzNcsZc(ewbhxhMap, 3));
        zcfzb.setYfzkQmsQy(getZcfzQmsQy(ewbhxhMap, 3));
        zcfzb.setYfzkNcsQy(getZcfzNcsQy(ewbhxhMap, 3));
        //4  ZC:应收股利  QY:预收账款
        zcfzb.setYsglQmsZc(getZcfzQmsZc(ewbhxhMap, 4));
        zcfzb.setYsglNcsZc(getZcfzNcsZc(ewbhxhMap, 4));
        zcfzb.setYszkQmsQy(getZcfzQmsQy(ewbhxhMap, 4));
        zcfzb.setYszkNcsQy(getZcfzNcsQy(ewbhxhMap, 4));
        //5  ZC:应收利息  QY:应付工资
        zcfzb.setYslxQmsZc(getZcfzQmsZc(ewbhxhMap, 5));
        zcfzb.setYslxNcsZc(getZcfzNcsZc(ewbhxhMap, 5));
        zcfzb.setYfgzQmsQy(getZcfzQmsQy(ewbhxhMap, 5));
        zcfzb.setYfgzNcsQy(getZcfzNcsQy(ewbhxhMap, 5));
        //6  ZC:应收账款  QY:应付福利费
        zcfzb.setYszkQmsZc(getZcfzQmsZc(ewbhxhMap, 6));
        zcfzb.setYszkNcsZc(getZcfzNcsZc(ewbhxhMap, 6));
        zcfzb.setYfflfQmsQy(getZcfzQmsQy(ewbhxhMap, 6));
        zcfzb.setYfflfNcsQy(getZcfzNcsQy(ewbhxhMap, 6));
        //7  ZC:其他应收款  QY:应付股利
        zcfzb.setQtyskQmsZc(getZcfzQmsZc(ewbhxhMap, 7));
        zcfzb.setQtyskNcsZc(getZcfzNcsZc(ewbhxhMap, 7));
        zcfzb.setYfglQmsQy(getZcfzQmsQy(ewbhxhMap, 7));
        zcfzb.setYfglNcsQy(getZcfzNcsQy(ewbhxhMap, 7));
        //8  ZC:预付账款  QY:应交税金
        zcfzb.setYfzkQmsZc(getZcfzQmsZc(ewbhxhMap, 8));
        zcfzb.setYfzkNcsZc(getZcfzNcsZc(ewbhxhMap, 8));
        zcfzb.setYjsjQmsQy(getZcfzQmsQy(ewbhxhMap, 8));
        zcfzb.setYjsjNcsQy(getZcfzNcsQy(ewbhxhMap, 8));
        //9  ZC:应收补贴款  QY:其他应交款
        zcfzb.setYsbtkQmsZc(getZcfzQmsZc(ewbhxhMap, 9));
        zcfzb.setYsbtkNcsZc(getZcfzNcsZc(ewbhxhMap, 9));
        zcfzb.setQtyjkQmsQy(getZcfzQmsQy(ewbhxhMap, 9));
        zcfzb.setQtyjkNcsQy(getZcfzNcsQy(ewbhxhMap, 9));
        //10 ZC:存货  QY:其他应付款
        zcfzb.setChQmsZc(getZcfzQmsZc(ewbhxhMap, 10));
        zcfzb.setChNcsZc(getZcfzNcsZc(ewbhxhMap, 10));
        zcfzb.setQtyfkQmsQy(getZcfzQmsQy(ewbhxhMap, 10));
        zcfzb.setQtyfkNcsQy(getZcfzNcsQy(ewbhxhMap, 10));
        //11 ZC:待摊费用  QY:预提费用
        zcfzb.setDtfyQmsZc(getZcfzQmsZc(ewbhxhMap, 11));
        zcfzb.setDtfyNcsZc(getZcfzNcsZc(ewbhxhMap, 11));
        zcfzb.setYtfyQmsQy(getZcfzQmsQy(ewbhxhMap, 11));
        zcfzb.setYtfyNcsQy(getZcfzNcsQy(ewbhxhMap, 11));
        //12 ZC:一年内到期的长期债权投资  QY:预计负债
        zcfzb.setYnndqdcqzqtzQmsZc(getZcfzQmsZc(ewbhxhMap, 12));
        zcfzb.setYnndqdcqzqtzNcsZc(getZcfzNcsZc(ewbhxhMap, 12));
        zcfzb.setYjfzQmsQy(getZcfzQmsQy(ewbhxhMap, 12));
        zcfzb.setYjfzNcsQy(getZcfzNcsQy(ewbhxhMap, 12));
        //13 ZC:其他流动资产  QY:一年内到期的长期负债
        zcfzb.setQtldzcQmsZc(getZcfzQmsZc(ewbhxhMap, 13));
        zcfzb.setQtldzcNcsZc(getZcfzNcsZc(ewbhxhMap, 13));
        zcfzb.setYnndqdcqfzQmsQy(getZcfzQmsQy(ewbhxhMap, 13));
        zcfzb.setYnndqdcqfzNcsQy(getZcfzNcsQy(ewbhxhMap, 13));
        //14 ZC:流动资产合计  QY:其他流动负债
        zcfzb.setLdzchjQmsZc(getZcfzQmsZc(ewbhxhMap, 14));
        zcfzb.setLdzchjNcsZc(getZcfzNcsZc(ewbhxhMap, 14));
        zcfzb.setQtldfzQmsQy(getZcfzQmsQy(ewbhxhMap, 14));
        zcfzb.setQtldfzNcsQy(getZcfzNcsQy(ewbhxhMap, 14));
        //15 ZC:长期股权投资  QY:流动负债合计
        zcfzb.setCqgqtzQmsZc(getZcfzQmsZc(ewbhxhMap, 15));
        zcfzb.setCqgqtzNcsZc(getZcfzNcsZc(ewbhxhMap, 15));
        zcfzb.setLdfzhjQmsQy(getZcfzQmsQy(ewbhxhMap, 15));
        zcfzb.setLdfzhjNcsQy(getZcfzNcsQy(ewbhxhMap, 15));
        //16 ZC:长期债权投资  QY:
        zcfzb.setCqzqtzQmsZc(getZcfzQmsZc(ewbhxhMap, 16));
        zcfzb.setCqzqtzNcsZc(getZcfzNcsZc(ewbhxhMap, 16));
        //17 ZC:长期投资合计  QY:长期借款
        zcfzb.setCqtzhjQmsZc(getZcfzQmsZc(ewbhxhMap, 17));
        zcfzb.setCqtzhjNcsZc(getZcfzNcsZc(ewbhxhMap, 17));
        zcfzb.setCqjkQmsQy(getZcfzQmsQy(ewbhxhMap, 17));
        zcfzb.setCqjkNcsQy(getZcfzNcsQy(ewbhxhMap, 17));
        //18 ZC:  QY:应付债券
        zcfzb.setYfzqQmsQy(getZcfzQmsQy(ewbhxhMap, 18));
        zcfzb.setYfzqNcsQy(getZcfzNcsQy(ewbhxhMap, 18));
        //19 ZC:固定资产原价  QY:长期应付款
        zcfzb.setGdzcyjQmsZc(getZcfzQmsZc(ewbhxhMap, 19));
        zcfzb.setGdzcyjNcsZc(getZcfzNcsZc(ewbhxhMap, 19));
        zcfzb.setCqyfkQmsQy(getZcfzQmsQy(ewbhxhMap, 19));
        zcfzb.setCqyfkNcsQy(getZcfzNcsQy(ewbhxhMap, 19));
        //20 ZC:减:累计折旧  QY:专项应付款
        zcfzb.setJljzjQmsZc(getZcfzQmsZc(ewbhxhMap, 20));
        zcfzb.setJljzjNcsZc(getZcfzNcsZc(ewbhxhMap, 20));
        zcfzb.setZxyfkQmsQy(getZcfzQmsQy(ewbhxhMap, 20));
        zcfzb.setZxyfkNcsQy(getZcfzNcsQy(ewbhxhMap, 20));
        //21 ZC:固定资产净值  QY:其他长期负债
        zcfzb.setGdzcjzQmsZc(getZcfzQmsZc(ewbhxhMap, 21));
        zcfzb.setGdzcjzNcsZc(getZcfzNcsZc(ewbhxhMap, 21));
        zcfzb.setQtcqfzQmsQy(getZcfzQmsQy(ewbhxhMap, 21));
        zcfzb.setQtcqfzNcsQy(getZcfzNcsQy(ewbhxhMap, 21));
        //22 ZC:减:固定资产减值准备  QY:长期负债合计
        zcfzb.setJgdzcjzzbQmsZc(getZcfzQmsZc(ewbhxhMap, 22));
        zcfzb.setJgdzcjzzbNcsZc(getZcfzNcsZc(ewbhxhMap, 22));
        zcfzb.setCqfzhjQmsQy(getZcfzQmsQy(ewbhxhMap, 22));
        zcfzb.setCqfzhjNcsQy(getZcfzNcsQy(ewbhxhMap, 22));
        //23 ZC:固定资产净额  QY:
        zcfzb.setGdzcjeQmsZc(getZcfzQmsZc(ewbhxhMap, 23));
        zcfzb.setGdzcjeNcsZc(getZcfzNcsZc(ewbhxhMap, 23));
        //24 ZC:工程物资  QY:递延税款贷项
        zcfzb.setGcwzQmsZc(getZcfzQmsZc(ewbhxhMap, 24));
        zcfzb.setGcwzNcsZc(getZcfzNcsZc(ewbhxhMap, 24));
        zcfzb.setDyskdxQmsQy(getZcfzQmsQy(ewbhxhMap, 24));
        zcfzb.setDyskdxNcsQy(getZcfzNcsQy(ewbhxhMap, 24));
        //25 ZC:在建工程  QY:负债合计
        zcfzb.setZjgcQmsZc(getZcfzQmsZc(ewbhxhMap, 25));
        zcfzb.setZjgcNcsZc(getZcfzNcsZc(ewbhxhMap, 25));
        zcfzb.setFzhjQmsQy(getZcfzQmsQy(ewbhxhMap, 25));
        zcfzb.setFzhjNcsQy(getZcfzNcsQy(ewbhxhMap, 25));
        //26 ZC:固定资产清理  QY:
        zcfzb.setGdzcqlQmsZc(getZcfzQmsZc(ewbhxhMap, 26));
        zcfzb.setGdzcqlNcsZc(getZcfzNcsZc(ewbhxhMap, 26));
        //27 ZC:固定资产合计  QY:
        zcfzb.setGdzchjQmsZc(getZcfzQmsZc(ewbhxhMap, 27));
        zcfzb.setGdzchjNcsZc(getZcfzNcsZc(ewbhxhMap, 27));
        //28 ZC:  QY:实收资本(或股本)
        zcfzb.setSszbhgbQmsQy(getZcfzQmsQy(ewbhxhMap, 28));
        zcfzb.setSszbhgbNcsQy(getZcfzNcsQy(ewbhxhMap, 28));
        //29 ZC:无形资产  QY:减:已归还投资
        zcfzb.setWxzcQmsZc(getZcfzQmsZc(ewbhxhMap, 29));
        zcfzb.setWxzcNcsZc(getZcfzNcsZc(ewbhxhMap, 29));
        zcfzb.setJyghtzQmsQy(getZcfzQmsQy(ewbhxhMap, 29));
        zcfzb.setJyghtzNcsQy(getZcfzNcsQy(ewbhxhMap, 29));
        //30 ZC:长期待摊费用  QY:实收资本(或股本)净额
        zcfzb.setCqdtfyQmsZc(getZcfzQmsZc(ewbhxhMap, 30));
        zcfzb.setCqdtfyNcsZc(getZcfzNcsZc(ewbhxhMap, 30));
        zcfzb.setSszbhgbjeQmsQy(getZcfzQmsQy(ewbhxhMap, 30));
        zcfzb.setSszbhgbjeNcsQy(getZcfzNcsQy(ewbhxhMap, 30));
        //31 ZC:其他长期资产  QY:资本公积
        zcfzb.setQtcqzcQmsZc(getZcfzQmsZc(ewbhxhMap, 31));
        zcfzb.setQtcqzcNcsZc(getZcfzNcsZc(ewbhxhMap, 31));
        zcfzb.setZbgjQmsQy(getZcfzQmsQy(ewbhxhMap, 31));
        zcfzb.setZbgjNcsQy(getZcfzNcsQy(ewbhxhMap, 31));
        //32 ZC:无形资产及其他资产合计  QY:盈余公积
        zcfzb.setWxzcjqtzchjQmsZc(getZcfzQmsZc(ewbhxhMap, 32));
        zcfzb.setWxzcjqtzchjNcsZc(getZcfzNcsZc(ewbhxhMap, 32));
        zcfzb.setYygjQmsQy(getZcfzQmsQy(ewbhxhMap, 32));
        zcfzb.setYygjNcsQy(getZcfzNcsQy(ewbhxhMap, 32));
        //33 ZC:  QY:其中:法定公益金
        zcfzb.setQzfdgyjQmsQy(getZcfzQmsQy(ewbhxhMap, 33));
        zcfzb.setQzfdgyjNcsQy(getZcfzNcsQy(ewbhxhMap, 33));
        //34 ZC:  QY:未分配利润
        zcfzb.setWfplrQmsQy(getZcfzQmsQy(ewbhxhMap, 34));
        zcfzb.setWfplrNcsQy(getZcfzNcsQy(ewbhxhMap, 34));
        //35 ZC:递延税款借项  QY:所有者权益(或股东权益)合计
        zcfzb.setDyskjxQmsZc(getZcfzQmsZc(ewbhxhMap, 35));
        zcfzb.setDyskjxNcsZc(getZcfzNcsZc(ewbhxhMap, 35));
        zcfzb.setSyzqyhgdqyhjQmsQy(getZcfzQmsQy(ewbhxhMap, 35));
        zcfzb.setSyzqyhgdqyhjNcsQy(getZcfzNcsQy(ewbhxhMap, 35));
        //36 ZC:资产合计  QY:负债和所有者权益(或股东权益)总计
        zcfzb.setZchjQmsZc(getZcfzQmsZc(ewbhxhMap, 36));
        zcfzb.setZchjNcsZc(getZcfzNcsZc(ewbhxhMap, 36));
        zcfzb.setFzhsyzqyhgdqyzjQmsQy(getZcfzQmsQy(ewbhxhMap, 36));
        zcfzb.setFzhsyzqyhgdqyzjNcsQy(getZcfzNcsQy(ewbhxhMap, 36));
    }

    /**
     * 利润表-本月数
     */
    public static Double getLrbBys(Map<String, QykjzdcwbblrbxxGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        QykjzdcwbblrbxxGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getBys());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("利润表第{}行数据没有bys,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }
    /**
     * 利润表-本年累计数
     */
    public static Double getLrbBnljs(Map<String, QykjzdcwbblrbxxGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        QykjzdcwbblrbxxGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getBnljs());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("利润表第{}行数据没有bnljs,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }
    /**
     * 现金流量表-金额
     */
    public static Double getXjllbJe(Map<String, QykjzdcwbbxjllbxxGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        QykjzdcwbbxjllbxxGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getJe());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("现金流量表第{}行数据没有Je,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }

    /**
     * 资产负债表 - 期末数资产
     * @param ewbhxhMap
     * @param rowNumber
     * @return
     */
    public static Double getZcfzQmsZc(Map<String, ZcfzbdxxGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        ZcfzbdxxGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getQmsZc());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("资产负债表第{}行数据没有qmsZc,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }

    /**
     * 资产负债表 - 年初数资产
     * @param ewbhxhMap
     * @param rowNumber
     * @return
     */
    public static Double getZcfzNcsZc(Map<String, ZcfzbdxxGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        ZcfzbdxxGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getNcsZc());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("资产负债表第{}行数据没有ncsZc,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }
    /**
     * 资产负债表 - 期末数权益
     * @param ewbhxhMap
     * @param rowNumber
     * @return
     */
    public static Double getZcfzQmsQy(Map<String, ZcfzbdxxGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        ZcfzbdxxGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getQmsQy());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("资产负债表第{}行数据没有qmsQy,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }

    /**
     * 资产负债表 - 期末数权益
     * @param ewbhxhMap
     * @param rowNumber
     * @return
     */
    public static Double getZcfzNcsQy(Map<String, ZcfzbdxxGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        ZcfzbdxxGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getNcsQy());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("资产负债表第{}行数据没有ncsQy,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }
}
